#include <my_header.h>
#include <string.h>
#define BUF_SIZE 4096

/* Usage: mkfifo 创建管道文件 */
int main(void){    
    int fd_read = open("data.pipe", O_RDONLY);
    ERROR_CHECK(fd_read, -1, "fd2_read");
    char recvbuf[BUF_SIZE] = {0};

    // B read pipe and print
    bzero(recvbuf, sizeof(recvbuf));
    ssize_t read_count = read(fd_read, recvbuf, sizeof(recvbuf));
    if(read_count <= 0) return -1;
    recvbuf[read_count] = '\0';
    printf("%s", recvbuf);
    fflush(stdout);

    close(fd_read);
    return 0;
}

